<?php
require_once("./config/config.inc.php");
require_once('./config/ucenter.inc.php');
require_once('./uc_client/client.php');

$cookieAuth = $_COOKIE['project4u_auth'];
if(!empty($cookieAuth)) {
    list($auth_uid, $auth_username) = explode("\t", uc_authcode($cookieAuth, 'DECODE'));
} else {
    $auth_uid = $auth_username = '';
}

if ($auth_uid <= 0 || $auth_username == '') {
    $SEC->checkSession();
    exit;
} else if ($SEC->sUserID <=0 || $SEC->sUserName == '') {
    $_SESSION['cfg_user_id']   = $auth_uid;
    $_SESSION["cfg_user_name"] = $auth_username;
    $SEC->sUserID = $auth_uid;
    $SEC->sUserName = $auth_username;
}

//show main menu
$firstMenu = array();
$secondMenu = array();

$sql  = "SELECT `MENUCODE`,`UPMENUCODE`,`MENUNAME`,`URL`,`IMAGESRC`,`TIP` FROM ".$TABLE_SYSTEM_MENU;
$sql .= " ORDER BY `UPMENUCODE`,`SHOWORDER`";

$stmt = $DB->query($sql);
while ($row = $DB->fetchRow($stmt)) {
    if ($row['UPMENUCODE'] == '0') {
        $firstMenu[] = $row;
    } else {
        $secondMenu[] = $row;
    }
}
$DB->freeResult($stmt);

$SM->assign('firstMenu', $firstMenu);
$SM->assign('secondMenu', $secondMenu);
$SM->assign("sUserName" ,$SEC->sUserName);

$SM->display('index.html');
?>
